<?php
/**
 * 功能：邮件发送函数
 * @param string $to 目标邮箱
 * @param string $subject 邮件主题（标题）
 * @param string $to 邮件内容
 * @return bool true
 */
function sendMail($to, $subject, $content)
{

    $mail = new PHPMailer\PHPMailer\PHPMailer();
    // 装配邮件服务器
    if (config('MAIL_SMTP')) {
        $mail->IsSMTP();
    }
    $mail->Host = config('MAIL_HOST');  //这里的参数解释见下面的配置信息注释
    $mail->SMTPAuth = config('MAIL_SMTPAUTH');
    $mail->Username = config('MAIL_USERNAME');
    $mail->Password = config('MAIL_PASSWORD');
    $mail->SMTPSecure = config('MAIL_SECURE');
    $mail->CharSet = config('MAIL_CHARSET');
    // 装配邮件头信息
    $mail->From = config('MAIL_USERNAME');
    $mail->AddAddress($to);
    $mail->FromName = config('MAIL_FROMNAME');
    $mail->IsHTML(config('MAIL_ISHTML'));
    // 装配邮件正文信息
    $mail->Subject = $subject;
    $mail->Body = $content;
    // 发送邮件
    return $mail->send() ? true : $mail->ErrorInfo;
}